import { uploadType } from '@/utils/util'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '申诉时间',
			prop: 'createTime',
			type: 'text',
			span: 12,
			readonly: true,
		},
		{
			label: '所属区',
			prop: 'orgAreaName',
			type: 'text',
			span: 12,
			readonly: true,
		},
		{
			label: '申诉人姓名',
			prop: 'createUserName',
			type: 'text',
			span: 12,
			readonly: true,
		},
		{
			label: '申诉人联系方式',
			prop: 'createPhone',
			type: 'text',
			span: 12,
			readonly: true,
		},
		{
			label: '申诉原因',
			prop: 'appealReasonLabel',
			type: 'text',
			span: 12,
			readonly: true,
		},
		{
			label: '申诉说明',
			prop: 'appealDescribe',
			type: 'text',
			span: 12,
			readonly: true,
		},
		{
			label: '申诉证明材料',
			prop: 'appealMaterial',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 24,
			onlyReady: true,
		},

		{
			label: '处理结果',
			prop: 'handleStatus',
			propName: 'handleStatusLabel',
			type: 'radio',
			dicData: [
				{
					label: '通过',
					value: '1',
				},
				{
					label: '待核实',
					value: '2',
				},
				{
					label: '驳回',
					value: '3',
				},
				{
					label: '不通过',
					value: '4',
				},
			],
			rules: [{ required: true, message: '请选择处理结果' }],
			span: 24,
		},
		{
			label: '申诉反馈描述',
			prop: 'handleNote',
			type: 'textarea',
			rules: [{ required: true, message: '请输入申诉反馈描述' }],
			span: 24,
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '申诉编号',
			prop: 'appealNo',
			type: 'input',
			span: 8,
		},
		{
			label: '申诉提交人',
			prop: 'createUserName',
			type: 'input',
			span: 8,
		},
		{
			label: '申诉人联系方式',
			prop: 'createPhone',
			type: 'input',
			span: 8,
		},
		{
			label: '申诉原因',
			prop: 'appealReasonLabel',
			type: 'input',
			code: 'APPEAL_REASON',
			span: 8,
		},
		{
			label: '申诉时间',
			prop: 'createTimeBetween',
			type: 'dateBetween',
			span: 8,
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
		},
		{
			label: '申诉结果',
			prop: 'handleStatus',
			type: 'select',
			dicData: [
				{
					label: '待处理',
					value: 0,
				},
				{
					label: '通过',
					value: 1,
				},
				{
					label: '待核实',
					value: 2,
				},
				{
					label: '驳回',
					value: 3,
				},
				{
					label: '不通过',
					value: 4,
				},
			],
			span: 8,
		},
		{
			label: '处理人',
			prop: 'handleUserName',
			type: 'input',
			span: 8,
		},
		{
			label: '处理时间',
			prop: 'handleTimeBetween',
			type: 'dateBetween',
			span: 8,
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '申诉编号', prop: 'appealNo' },
		{ label: '工单编号', prop: 'orderNo' },
		{ label: '所属区', prop: 'orgAreaName' },
		{ label: '申诉提交人', prop: 'createUserName' },
		{ label: '申诉人联系方式', prop: 'createPhone' },
		{ label: '申诉原因', prop: 'appealReasonLabel' },
		{ label: '申诉时间', prop: 'createTime' },
		{
			label: '申诉结果',
			prop: 'handleStatus',
			custome: 'tag',
			dicData: [
				{
					label: '待处理',
					value: 0,
					type: 'warning',
				},
				{
					label: '通过',
					value: 1,
					type: 'success',
				},
				{
					label: '待核实',
					value: 2,
					type: 'primary',
				},
				{
					label: '驳回',
					value: 3,
					type: 'danger',
				},
				{
					label: '不通过',
					value: 4,
					type: 'danger',
				},
			],
		},
		{ label: '处理人', prop: 'handleUserName' },
		{ label: '处理时间', prop: 'handleTime' },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_omAppeal_page',
	edit: 'view_omAppeal_approval',
	detail: 'view_omAppeal_view',
}
export const auth = {
	...api,
}
export const baseConfig = {
	pageName: '申诉管理',
	dictcodes: ['APPEAL_REASON'],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'createUserName',
	exportMqTopic: '/ning/export/',
	api,
	auth,
	paramsObj: {
		fromType: 2,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: auth.edit,
			text: true,
			show: true,
			condition: (row) => {
				return row.handleStatus == 0 || row.handleStatus == 2
			},
		},
		{
			icon: 'detail',
			label: '详情',
			type: 'primary',
			operate: 'detail',
			auth: auth.index,
			text: true,
			show: true,
		},
	],
	operateFormate: async (form, type) => {
		return new Promise((resolve, reject) => {
			if (type == 'edit') {
				form.handleNote = ''
				form.idList = [form.id]
			}
			resolve(form)
		})
	},
	saveFormate: async (form) => {
		return new Promise((resolve, reject) => {
			resolve(form)
		})
	},
	beforeOnLoadFormate: async (query) => {
		return new Promise((resolve, reject) => {
			resolve(query)
		})
	},
	onLoadFormate: async (arr) => {
		return new Promise((resolve, reject) => {
			resolve(arr)
		})
	},
	dialogConfig: {
		width: '75%',
	},
	searchConfig,
	formConfig,
	tableConfig,
	detailConfig: formConfig,
}
